﻿using OMG.Fill.Mulberry.UI.App_Start;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using System.Web.Http.Cors;

namespace OMG.Fill.Mulberry.UI
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            var cors = new EnableCorsAttribute("*", "*", "*");
            cors.SupportsCredentials = true;
            config.EnableCors(cors);
            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
               name: "DefaultApi",
               routeTemplate: "api/{controller}/{action}/{id}",//CustomConstraint 需要增加{action}/
               defaults: new { action = RouteParameter.Optional, id = RouteParameter.Optional },
               constraints: new { action = new CustomConstraint() }
           );
        }
    }
}
